import { loginWxMinSimple } from "@/services/login.js"

const state = {
	token: "",
	userInfo: {}
}

const mutations = {
	SETPROFILE(state, userInfo){
		state.userInfo = userInfo
		state.token = userInfo.token
	},
	CLEARUSERINFO(state){
		state.token = ''
		state.userInfo = {}
	},
}

const actions = {
	async setProfile({commit}){
		const res = await loginWxMinSimple('17899080419')
		console.log(res);
		commit("SETPROFILE", res.result);
	},
	// 清除用户信息
	clearProfile({commit}){
		commit("CLEARUSERINFO");
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions
}